package com.daykw.xiaohongshu.task;

import java.util.HashMap;
import java.util.Map;

import org.apache.log4j.Logger;
import org.springframework.util.StringUtils;

import com.daykw.xiaohongshu.http.HttpBase;
import com.daykw.xiaohongshu.util.QuartzManager;

public class RedisIpTask extends CustmTask {

	private static Logger logger = Logger.getLogger(RedisIpTask.class);
	
	@Override
	public void doStart() {
//		logger.info("初始化获取RedisIpTask任务...");
//		try {
//			if (QuartzManager.getTrigger("RedisIpTask") == null) {
//				QuartzManager.addJob("RedisIpTask", this, "0/5 * * * * ?");
//			} else {
//				logger.info("已经存在任务:RedisIpTask");
//			}
//		} catch (Exception e) {
//			logger.error("", e);
//		}
	}

	@Override
	public void doWork() {
		
	}
	
//	public static void main(String args[])throws Exception{
//		String url_1 = "http://www.httpdaili.com/api.asp?ddbh=121733695160938502&old=1&noinfo=true&sl=100";
//		//String url_2 = "http://www.wndaili.cn/api/?key=20180113200228663&getnum=100&area=1&formats=2&proxytype=01";
//		HttpBase http = new HttpBase();
//		String ip = http.http(url_1, new HashMap<String,String>());
//		String url = "https://www.xiaohongshu.com/search_result/fresh";
//		Map<String, String> headers = new HashMap<String, String>();
//		headers.put("Accept", "application/json, text/plain, */*");
//		headers.put("Accept-Encoding", "gzip, deflate, sdch");
//		headers.put("Accept-Language", "zh-CN,zh;q=0.8");
//		headers.put("Cache-Control", "max-age=0");
//		headers.put("Cookie",
//				"xhsTrackerId=9ed6751b-39ee-4682-c610-b1f96d102595; exp_ids=m_TestA-ctl2; Hm_lvt_d0ae755ac51e3c5ff9b1596b0c09c826=1515084426; Hm_lpvt_d0ae755ac51e3c5ff9b1596b0c09c826=1515084426; Hm_lvt_9df7d19786b04345ae62033bd17f6278=1515084426; Hm_lpvt_9df7d19786b04345ae62033bd17f6278=1515084430; xhs_spid.5dde=5fc5a7b7c9148948.1515084421.1.1515084433.1515084421.951e5781-af93-46c0-8994-797318048a51; xhs_spses.5dde=*");
//		headers.put("Host", "www.xiaohongshu.com");
//		headers.put("Referer", "http://www.xiaohongshu.com/");
//		headers.put("Upgrade-Insecure-Requests", "1");
//		headers.put("User-Agent",
//				"Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36");
//		String ips[] = ip.split("\n");
//		int i=0;
//		int a=0;
//		int b=0;
//		for(String s:ips){
//			System.out.println("总"+i);
//			System.out.println("失败"+a);
//			System.out.println("成功"+b);
//			i++;
//			try{
//				String ss = http.turl(url, "utf8", headers, s);
//				if(StringUtils.isEmpty(ss) || ss.equals("fail")){
//					a++;
//				}else{
//					b++;
//				}
//			}catch(Exception e){
//				e.printStackTrace();
//				a++;
//			}
//		}
//		System.out.println("总"+i);
//		System.out.println("失败"+a);
//		System.out.println("成功"+b);
//		//System.out.println(ip);
//		
//	}
	

}
